Skip to content

fix: set proper User-Agent header on outgoing HTTP requests#7162

Closed
MD-Mushfiqur123 wants to merge 1 commit into
yarnpkg:masterfrom
MD-Mushfiqur123:fix/user-agent-header
Closed

fix: set proper User-Agent header on outgoing HTTP requests#7162
MD-Mushfiqur123 wants to merge 1 commit into
yarnpkg:masterfrom
MD-Mushfiqur123:fix/user-agent-header

Conversation

@MD-Mushfiqur123

Copy link
Copy Markdown

What

Set a meaningful User-Agent header on all outgoing HTTP requests, changing from the default got (https://github.com/sindresorhus/got) to yarn/<version> node/<node_version>.

Why

As a sys admin, I want package managers to identify themselves with a meaningful User-Agent header, but Yarn 4 currently sends "got (https://github.com/sindresorhus/got)" instead of identifying itself as Yarn. This makes it impossible to distinguish Yarn traffic and determine its exact version, preventing us from enforcing package manager allow-lists across the organization.

This follows the convention already established by npm (npm/x.x.x node/vx.x.x) and pnpm (pnpm/x.x.x).

How

  • Imported YarnVersion from the YarnVersion module
  • Set a default user-agent header on the got client, with caller-supplied headers taking precedence via spread ordering

Fixes #7146

@arcanis arcanis closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Set a proper User-Agent header on outgoing HTTP request

3 participants